#! encoding=utf-8
import requests
from requests import Session
import socket


host= "10.200.6.46"
port=80
##############multi https transction in one tcp##########################
# url="http://10.200.10.110/autotest/test.html"
# bodypara="aaaaaaa"
# headers ={}
# s = Session()
# for i in range(10):
#     response = s.post(url=url, data=bodypara, verify=False, timeout=10, headers=headers)
#     print response.status_code
#

###################### http pipeline###########################
requests ="""GET /test.html HTTP/1.1
Host: 10.200.6.46
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:42.0) Gecko/20100101 Firefox/42.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Cache-Control: max-age=0
Referer: https://support.scrt.ch/view.php
Cookie: OSTSESSID=kenkkjuiemnpueev8ilnfaivr6;cookiesession1=27B88163SAJF1VHFEADDMIHYWUI73D1F
Connection: keep-alive
Content-Length: 0

GET /test.html HTTP/1.1
Host: 10.200.6.46
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:42.0) Gecko/20100101 Firefox/42.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate

GET /test.html HTTP/1.1
Host: 10.200.6.46
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:42.0) Gecko/20100101 Firefox/42.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate

"""


requests=requests.replace("\n","\r\n")
sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sock.connect((host,port))
sock.send(requests)
while True:
    recv = sock.recv(4096)
    if not len(recv):break
    print recv

sock.close()
